package com.example.mq1.demo;

import com.example.mq1.mqclient.Channel;
import com.example.mq1.mqclient.Connection;
import com.example.mq1.mqclient.ConnectionFactory;
import com.example.mq1.mqserver.core.ExchangeType;

import java.io.IOException;

public class Produce {

    public static void main(String[] args) throws IOException, InterruptedException {
        ConnectionFactory connectionFactory = new ConnectionFactory();
        connectionFactory.setHost("127.0.0.1");
        connectionFactory.setPort(9090);
        Connection connection = connectionFactory.newConnection();
        Channel channel = connection.createChannel();

        channel.exchangeDeclare("testExchange", ExchangeType.DRICT, true,
                false, null);
        channel.queueDeclare("testQueue", true, false, false, null);
        channel.queueBind("testExchange", "testQueue", "");

        channel.basicPublish("testExchange", "testQueue", null, "hello! cyk".getBytes());


        channel.close();
        connection.close();

    }

}
